package com.maben.udp.V2;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.ip.udp.UnicastSendingMessageHandler;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.stereotype.Service;

@Slf4j(topic = "m.UdpProvider")
@Service
public class UdpProvider {

    @Autowired
    private UnicastSendingMessageHandler sendMsgService;

    public void sendMessage(String message) {
        log.info("发送UDP消息: {}", message);
        sendMsgService.handleMessage(MessageBuilder.withPayload(message).build());
    }
}